﻿
namespace ApplicationGenerator.DataAccess
{
    public class ListDataBaseCommands : IDataBaseCommands
    {
        #region SQL Commands

        private const string CreateListsTableSchema = "CREATE TABLE AG_LISTS(" +
                                                        "[AG_ID] [uniqueidentifier] NOT NULL," +
                                                        "[AG_NAME] [nvarchar](50) NOT NULL UNIQUE NONCLUSTERED," +
                                                        "[AG_BINARY_DATA] [varbinary](max) NOT NULL" +
                                                        ")";
        private const string InsertToAgListsTable = "INSERT INTO AG_LISTS  VALUES(@id,@name,@binData)";
        private const string SelectListsFromAgListsTable = "SELECT AG_BINARY_DATA FROM AG_LISTS WHERE AG_ID = @id;";
        private const string SelectListsFromAgListsTableByName = "SELECT AG_BINARY_DATA FROM AG_LISTS " +
                                                                "WHERE AG_NAME = @name;";
        private const string UpdateListFromAgListsTable = "UPDATE AG_LISTS SET AG_BINARY_DATA = @bin_data WHERE AG_NAME = @name;";
        private const string SelectListsNames = "SELECT AG_NAME FROM AG_LISTS;";
        private const string SelectVersionInfoFromAgListsTable = "SELECT AG_ID,AG_NAME FROM AG_LISTS";

        #endregion

        #region Methods

        public string CreateTableCommand()
        {
            return CreateListsTableSchema;
        }

        public string InsertToTableCommand()
        {
            return InsertToAgListsTable;
        }

        public string UpdateToTableCommand()
        {
            return UpdateListFromAgListsTable;
        }

        public string SelectFromTableCommand()
        {
            return SelectListsFromAgListsTable;
        }

        public string SelectFromTableByNameCommand()
        {
            return SelectListsFromAgListsTableByName;
        }

        public string SelectNames()
        {
            return SelectListsNames;
        }

        public string SelectVersionInfo()
        {
            return SelectVersionInfoFromAgListsTable;
        }

        public string SelectName()
        {
            return "" ;
        }

        #endregion
    }
}
